package com.gwz.wxtime.chessboard.util;

import com.gwz.wxtime.chessboard.entity.Puke;

import java.util.ArrayList;
import java.util.List;

public class PukeUtil {
    public static List<Puke> initPuke() {
        //存储牌
        List<Puke> pukes = new ArrayList<Puke>();
        Integer huase1[] = {1, 2, 3, 4};
        Integer jqk[] = {11, 12, 13, 14,15};
        //给牌赋值
        for (int i = 3; i < 11; i++) {
            for (int j = 0; j < huase1.length; j++) {
                Puke puke = new Puke();
                puke.setNum(i);
                puke.setHuase(huase1[j]);
                pukes.add(puke);
            }
        }

        //给特殊牌赋值
        for (Integer teshu : jqk) {
            for (Integer hua1 : huase1) {
                Puke puke = new Puke();
                puke.setNum(teshu);
                puke.setHuase(hua1);
                pukes.add(puke);
            }
        }
        //大王小王赋值
        Puke puke11 = new Puke();
        puke11.setNum(999);
        pukes.add(puke11);
        Puke puke12 = new Puke();
        puke12.setNum(99);
        pukes.add(puke12);
        return pukes;
    }

    public static String translation(Integer num) {
        return switch (num) {
            case 14 -> "A";
            case 15 -> "2";
            case 11 -> "J";
            case 12 -> "Q";
            case 13 -> "K";
            case 99 -> "小王";
            case 999 -> "大王";
            default -> num + "";
        };
    }

    public static Integer translation(String str) {
        return switch (str) {
            case "A", "a" -> 14;
            case "2" -> 15;
            case "J", "j" -> 11;
            case "Q", "q" -> 12;
            case "K", "k" -> 13;
            case "小王" -> 99;
            case "大王" -> 999;
            default -> Integer.valueOf(str);
        };
    }

    public static String typeTrans(int type) {
        return switch (type) {
            case 1 -> "单";
            case 2 -> "双";
            case 3 -> "顺子";
            case 4 -> "三不带";
            case 5 -> "三带一";
            case 6 -> "三带二";
            case 7 -> "炸";
            case 8 -> "连对";
            case 9 -> "飞机不带";
            case 10 -> "飞机带1";
            case 11 -> "飞机带对";
            case 12 -> "四带2";
            case 13 -> "四带2对";
            case 14 -> "顺四不带";
            case 15 -> "顺四带2";
            case 16 -> "顺四带2对";
            default -> "出牌规则错误";
        };
    }
}
